$(function(){
	
	var check = $("input:checkbox");
	check.click(function(){
		if($(this).attr("checked")){
			check.attr("checked",false); 
			$(this).attr("checked",true);
		}
		
		$("#affirm").attr("disabled",!$(this).attr("checked"));
	});
	
	
	$("#affirm").click(function(){
		var arr = [];
		$("input:checked").each(function(i){
			arr[i]=$(this).val();
		});
		
		if(arr.length!=1){ 
			alert("请选择一条记录！");
			return;
		}
		
		$(this).attr("disabled",true);
		
		var ip=$("#ip").val();
		var id=$("#id").val();
		
		
		mask=document.createElement("div");
	    var W=$(document).width();
	    var H=$(document).height();
	    mask.id="mask";
	    mask.style.cssText="position:absolute;z-index:5;width:"+W+"px;height:"+H+"px;background:#000;filter:alpha(opacity=30);opacity:0.5;top:0;left:0;";
	    document.body.appendChild(mask);
	    var o = document.getElementById("change");
	  	o.style.display="block";
	  	o.style.top="200px";
	  	o.style.left="400px";
		
		$.ajax({
			   type: "POST",
			   url: "autochange!change.do",
			   data: "id="+id+"&ip="+ip+"&change="+arr[0],
			   timeout:20000,
			   success:function(o){
				   $('#change').css('display',"none");
		  			$('#mask').remove();
				   if(o==1){
					   alert("更换成功!");
				   }else{
					   alert("更换失败，清重新更换或者联系管理员!");
				   }
				   location.href="myip.do";
			   },
			   error:function(o){
				   $('#change').css('display',"none");
		  			$('#mask').remove();
				   alert("更换失败，清重新更换或者联系管理员!");
				   location.href="myip.do";
			   }
		});
	});
});